/**
 * 
 */
package org.statewalker.core.server;

import org.statewalker.core.ILock;

public class SyncProcessLock implements ILock {
    private boolean fLocked;

    public void lock() {
        fLocked = true;
    }

    public void unlock() {
        fLocked = false;
        synchronized (this) {
            fLocked = false;
            notifyAll();
        }
    }

    public void waitForUnlock() {
        try {
            while (fLocked) {
                synchronized (this) {
                    if (!fLocked)
                        break;
                    wait(100);
                }
            }
        } catch (InterruptedException e) {
        }
    }
}